package cn.hnu.qq.frame;

import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;

import cn.hnu.qq.client.controller.CenterController;
import cn.hnu.qq.client.panel.LogonPanel;

public class ClientFrame extends JFrame{
	
	public ClientFrame(){
		init();
	}
	
	private void init() {
		this.setResizable(false);
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.setVisible(true);
	}

	public ClientFrame(JPanel panel){
		this.setSize(panel.getSize());
		init();
	}
	
	public void refreshPanel(JPanel panel){
		this.getRootPane().removeAll();
		this.setSize(panel.getWidth()+10, panel.getHeight()+10);
		this.getRootPane().add(panel);
		this.validate();
	}
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
		public void run() {
			try {
				ClientFrame window = new ClientFrame();
				CenterController.setClient(window); //将窗口交给控制器管理
				window.refreshPanel(new LogonPanel());
				window.setVisible(true);
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	});
	}
	
}
